﻿//++
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
// Module Name:
//
//  InstantMessageSender.cs
//    
// Abstract:
//
//  This module is an implementation of IMessageSender for delivering NotificationItems
//  via instant message.
//  
//--

using System;
using System.Workflow.Runtime;
using Microsoft.Rtc.Collaboration;

namespace Microsoft.EnhancedReminders.Dispatcher.Workflow
{
    /// <summary>
    /// This module is an implementation of IMessageSender for delivering NotificationItems
    /// via instant message.
    /// </summary>
    [StopPoint(true)]
	public class InstantMessageSender : WorkflowMessageSender
	{
        /// <summary>
        /// ctor.
        /// </summary>
        /// <param name="conversation">The Conversation object to use for the call</param>
        /// <param name="runtime">The WorkflowRuntime to use for hosting the workflow used for the call</param>
        /// <param name="message">The message to be delivered</param>
        public InstantMessageSender(Conversation conversation, WorkflowRuntime runtime, NotificationItem message) :
            base(conversation, runtime, message) 
        { 
        }

        /// <summary>
        /// Returns the Type object for the Workflow class to use. In this case it's always InstantMessageReminder.
        /// </summary>
        protected override Type WorkflowType
        {
            get
            {
                return typeof(InstantMessageReminder);
            }
        }

        /// <summary>
        /// Sets notificationResult.HowContacted and then calls the base implementation
        /// of OnDeliveryCompleted.
        /// </summary>
        protected override void OnDeliveryCompleted(NotificationResult result)
        {
            result.HowContacted = NotificationChannelType.Communicator;
            base.OnDeliveryCompleted(result);
        }

        /// <summary>
        /// Initializes an InstantMessagingCall
        /// </summary>
        protected override bool InitializeCall()
        {
            _call = new InstantMessagingCall(_conversation);

            return true;
        }

        /// <summary>
        /// No-op.
        /// </summary>
        protected override void CleanupCall()
        {
        }

        
    }
}
